package org.jeecg.modules.demo.hd.controller;

import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.demo.hd.entity.AppGoldTotalday;
import org.jeecg.modules.demo.hd.service.IAppGoldTotaldayService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;

 /**
 * @Description: 金币每日统计汇总
 * @Author: jeecg-boot
 * @Date:   2025-04-26
 * @Version: V1.0
 */
@Api(tags="金币每日统计汇总")
@RestController
@RequestMapping("/hd/appGoldTotalday")
@Slf4j
public class AppGoldTotaldayController extends JeecgController<AppGoldTotalday, IAppGoldTotaldayService> {
	@Autowired
	private IAppGoldTotaldayService appGoldTotaldayService;
	
	/**
	 * 分页列表查询
	 *
	 * @param appGoldTotalday
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "app_gold_totalday-分页列表查询")
	@ApiOperation(value="金币收益每日汇总统计", notes="金币收益每日汇总统计")
	@GetMapping(value = "/list")
	public Result<IPage<AppGoldTotalday>> queryPageList(AppGoldTotalday appGoldTotalday,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
        QueryWrapper<AppGoldTotalday> queryWrapper = QueryGenerator.initQueryWrapper(appGoldTotalday, req.getParameterMap());
		Page<AppGoldTotalday> page = new Page<AppGoldTotalday>(pageNo, pageSize);
		IPage<AppGoldTotalday> pageList = appGoldTotaldayService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	
	/**
	 *   添加
	 *
	 * @param appGoldTotalday
	 * @return
	 */
	@AutoLog(value = "添加统计")
	@ApiOperation(value="app_gold_totalday-添加", notes="app_gold_totalday-添加")
	@RequiresPermissions("hd:app_gold_totalday:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody AppGoldTotalday appGoldTotalday) {
		appGoldTotaldayService.save(appGoldTotalday);
		// 查看当天数据


		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param appGoldTotalday
	 * @return
	 */
	@AutoLog(value = "app_gold_totalday-编辑")
	@ApiOperation(value="app_gold_totalday-编辑", notes="app_gold_totalday-编辑")
	@RequiresPermissions("hd:app_gold_totalday:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody AppGoldTotalday appGoldTotalday) {
		appGoldTotaldayService.updateById(appGoldTotalday);
		return Result.OK("编辑成功!");
	}


	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "app_gold_totalday-通过id查询")
	@ApiOperation(value="app_gold_totalday-通过id查询", notes="app_gold_totalday-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<AppGoldTotalday> queryById(@RequestParam(name="id",required=true) String id) {
		AppGoldTotalday appGoldTotalday = appGoldTotaldayService.getById(id);
		if(appGoldTotalday==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(appGoldTotalday);
	}


}
